#include "NBEngine.h"

using namespace EngineCore;

NBEngine::NBEngine() 
{
}

_hr NBEngine::LoadConfig()
{
	//TODO:
	//Here We Should Read Cfg File To Fill The Desc Struct
	m_EngineProp.AppName = L"NBE";
	m_EngineProp.Width = 300;
	m_EngineProp.Height = 200;
	m_EngineProp.RenderDllPath = L"../DLLs/DX12";

	return _OK;
}


NBEngine::~NBEngine()
{
}

_hr NBEngine::SetUp()
{
	_hr errCode = _OK;
	errCode = LoadConfig();
	_ERROR_CHECK(errCode);
	m_pPlatformLayer = PlatformLayer::Instance();
	errCode = m_pPlatformLayer->SetUp(m_EngineProp);
	m_factory.SetUp(m_EngineProp, m_pPlatformLayer);
	m_factory.MakeRenderEngine(m_pRenderEngine);
	m_pRenderEngine->SetUp(m_EngineProp,*m_pPlatformLayer);

	return _OK;
}

void NBEngine::Run()
{
	_hr errCode = _OK;

	//Desc: SubSystem to Lauch
	errCode = m_pPlatformLayer->Launch();
	//_ERROR_CHECK(errCode);

	//Desc: Subsystem to Tick
	while (1)
	{
		errCode = m_pPlatformLayer->Tick();
		errCode = m_pRenderEngine->Render();
	}

}

_hr NBEngine::TurnOff()
{
	return _OK;
}
